<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <%- include common %>
    <title>修改密码</title>
</head>
<body>
<%- include("head",{title:'changepass',username:username})%>
<div class="container container-fluid">
    <div class="row" >
        <div class="col-md-4 col-lg-4 col-sm-4">
            <h2 class="text-info">修改密码</h2>
            <form action="/users/register"  method="POST">
                <div class="form-group">
                    <label for="oldpass">旧密码</label>
                    <input  id="oldpass" type="text" class="form-control" placeholder="请输入用户名">
                </div>
                <div class="form-group">
                    <label for="newpass">新密码</label>
                    <input  id="newpass" type="text" class="form-control" placeholder="请输入手机号码">
                </div>
                <div class="form-group">
                    <label for="confirmnewpassword">确认新密码</label>
                    <input  id="confirmnewpassword" type="password" class="form-control" placeholder="请输入密码">
                </div>
               
                <div class="form-group">
                    <a href="/login" class="link">忘记密码？？？？找回密码</a>  
                </div>
                <div class="form-group">
                    <button type="button" data-username="<%- username %>" id="changebtn" class="btn btn-success">提交</button>
                    <button type="reset" class="btn btn-danger">重置</button>
                </div>
            </form>
        </div>
    </div>
</div>
 



<%- include foot %>

<script>
    $("#changebtn").click(function(){
        $.ajax({
            url:"/users/changepass",
            method:"POST",
            data:{
                oldpass:$("#oldpass").val(),
                newpass:$("#newpass").val(),
                username:$("#changebtn").attr("data-username")
            },
            success(res){
                console.log(res)
                if(res.code==200){
                    
                    if(res.type){
                        window.location.href="/login"
                    }
                    alert(res.msg)
                }
            }
        })
    })


</script>
</body>
</html>